package com.jy.controller;


import com.jy.common.enums.ResponseWrapper;
import com.jy.common.model.good.result.DeleteCartGoodsParam;
import com.jy.common.model.user.param.TakeCardReleaseParam;
import com.jy.common.tool.CommonTool;
import com.jy.service.CardHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 * 打卡记录表 前端控制器
 * </p>
 *
 * @author fzg
 * @since 2025-01-08
 */
@RestController
@RequestMapping("/card-history")
public class CardHistoryController {

    private final CardHistoryService cardHistoryService;


    public CardHistoryController(CardHistoryService cardHistoryService) {
        this.cardHistoryService = cardHistoryService;
    }


    /**
     * 打卡发布
     * @param params 打卡参数
     * @return ResponseWrapper
     */
    @PostMapping("/takeCardRelease")
    public ResponseWrapper takeCardRelease(HttpServletRequest request, @RequestBody @Validated TakeCardReleaseParam params) {
        return cardHistoryService.takeCardRelease(request,params);
    }

    /**
     * 获取用户的打卡记录全部信息
     * @return ResponseWrapper
     */
    @GetMapping("/getCardHistoryAllInfo")
    public ResponseWrapper getCardHistoryAllInfo(HttpServletRequest request, @RequestParam Integer userAid) {
        return cardHistoryService.getCardHistoryAllInfo(CommonTool.getUserAidByToken(request), userAid);
    }

    /**
     * 查询旅行卡排名信息
     * @param request request
     * @return ResponseWrapper
     */
    @GetMapping("/getAllRankInfo")
    public ResponseWrapper getAllRankInfo(HttpServletRequest request) {
        return cardHistoryService.getAllRankInfo(CommonTool.getUserAidByToken(request));
    }

}
